package com.example.broadcastreceiver;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.os.Vibrator;
import android.util.Log;

public class WallpaperReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {

		Log.i(this.getClass().getCanonicalName(), intent.getAction());
						
		Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
		v.vibrate(200);
		
		// UPGRADE 1
//		intent = new Intent();
//		intent.setClassName("com.example.servicetest", "com.example.servicetest.ServiceTest");
//		//intent = new Intent("com.example.servicetest.SERVICE");
//		context.startService(intent);

		// UPGRADE 2
		intent = new Intent();
		intent.setClassName("com.example.servicetest", "com.example.servicetest.ServiceTest");
		PendingIntent p = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
		AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
		am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 5000, 30000, p);
	}
}
